<?php

namespace app\server\notice\model;

use app\common\model\Config;
use app\server\notice\interfaces\MsgDriver;

/**
 * 邮件发送验证码
 *
 * Class EmsSimple
 * @package app\server\notice\model
 */
class EmsSimple implements MsgDriver
{

    /**
     * 简单策略发送
     *
     * @param array $params
     * @return boolean|string
     */
    public function msgSend(array $params = [])
    {
        $tem = Config::get('template.' . $params['tem'], 'ems');
        $title = $tem['title'];
        if ($tem['var_count'] != count($params['content'])) {
            return 'content is error';
        }
        $body = vsprintf($tem['body'], $params['content']);
        return (new Ems())->index($params['to'], $title, $body);
    }

}